import { clearToken, http, setToken } from "@/utils";
import { makeAutoObservable } from "mobx";

class LoginStore{
    token = '';
    constructor() {
        makeAutoObservable(this)
    }
    //登陆
    login = async ({mobile,code})=>{
        const res = await http.post('http://geek.itheima.net/v1_0/authorizations', {
            mobile,
            code
        })
        console.log('res--->',res,res.data.token)
        this.token = res.data.token;
        console.log('this.token-------->',this.token)
        // 还有这里哦！！
        setToken(this.token)
    }
    // 退出登录
    loginOut = () => {
        this.token = ''
        clearToken()
    }
}

export default LoginStore;